/*package com.gemantic.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;

import com.alibaba.druid.util.StringUtils;

import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;


@Configuration
@EnableCaching

public class RedisCacheConfiguration extends CachingConfigurerSupport {
    Logger logger = LoggerFactory.getLogger(RedisCacheConfiguration.class);

    @Value("${spring.redis.host}")
    private String host;

    @Value("${spring.redis.port}")
    private int port;


    @Value("${spring.redis.password}")
    private String password;
    
    @Value("${spring.redis.timeout}")
    private int timeout;

    @Value("${spring.redis.pool.max-idle}")
    private int maxIdle;

    @Value("${spring.redis.pool.max-wait}")
    private long maxWaitMillis;

    private static JedisPool jedisPool;
    @Bean
    public JedisPool redisPoolFactory() {
        logger.info("JedisPool注入成功！！");
        logger.info("redis地址：" + host + ":" + port);
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxIdle(maxIdle);
        jedisPoolConfig.setMaxWaitMillis(maxWaitMillis);
        if(StringUtils.isEmpty(password)){
        	 jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout);
        }else{
        	 jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout,password);
        }
       
        return jedisPool;
    }
    
    @Bean  
    public JedisPoolConfig getRedisConfig() {  
        JedisPoolConfig config = new JedisPoolConfig();  
        config.setMaxIdle(maxIdle);
        config.setMaxWaitMillis(maxWaitMillis);
        return config;  
    } 
    @Bean  
    public JedisConnectionFactory getConnectionFactory() {  
        JedisConnectionFactory factory = new JedisConnectionFactory();  
        factory.setUsePool(true);  
        JedisPoolConfig config = getRedisConfig();  
        factory.setPoolConfig(config);  
        logger.info("JedisConnectionFactory bean init success.");  
        return factory;  
    }  
  
    
    @Bean  
    public RedisTemplate<?, ?> getRedisTemplate() {  
        JedisConnectionFactory factory = getConnectionFactory();  
        logger.info(this.host+","+factory.getHostName()+","+factory.getDatabase());  
        logger.info(this.password+","+factory.getPassword());  
        logger.info(factory.getPoolConfig().getMaxIdle()+"");  
        factory.setHostName(this.host);  
        factory.setPassword(this.password);  
        factory.setPort(port);
        
        RedisTemplate<?, ?> template = new StringRedisTemplate(factory);  
        return template;  
    }  
    public JedisPool getJedisPool(){
    	if(null == jedisPool){
    		redisPoolFactory();
    	}
    	return jedisPool;
    }
}*/